/**
 * 
 */
package com.sdu.passager.bean;

import java.util.*;

import org.springframework.util.StringUtils;

/**
 * @author Administrator 表的实体类和数据的表对应
 */
public class TableBean {

	private String tableName;
	private List<Field> fields = new ArrayList<Field>();
	private String tableClassName;// //cap
	private String unCaptableClassName;// /uncap
	private String seqName;

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

	public List<Field> getFields() {
		return fields;
	}

	public void setFields(List<Field> fields) {
		this.fields = fields;
	}

	public String getTableClassName() {
		// //做简单处理,以后可以再加2012-07-21
//		String _tableName = tableName.replaceAll("_", "");// /去掉_
		String _tableName = loadName(tableName);// /去掉_
		_tableName = StringUtils.capitalize(_tableName);

		return _tableName;
	}

	public void setTableClassName(String tableClassName) {
		this.tableClassName = tableClassName;
	}

	public String getUnCaptableClassName() {
//		String _tableName = tableName.replaceAll("_", "");// /去掉_
		String _tableName = loadName(tableName);// /去掉_
		_tableName = StringUtils.uncapitalize(_tableName);
		return _tableName;
	}

	public void setUnCaptableClassName(String unCaptableClassName) {
		this.unCaptableClassName = unCaptableClassName;
	}

	public String getSeqName() {
		return seqName;
	}

	public void setSeqName(String seqName) {
		this.seqName = seqName;
	}

	/**
	 * @描述: 替换字符串并让它的下一个字母为大写 
	 * @作者: WeiYC
	 * @日期:2016-11-30
	 * @修改内容
	 * @参数： @param name
	 * @参数： @return    
	 * @return String   
	 * @throws
	 */
	public String loadName(String name) {
		String newString = "";
		int first = 0;
		while (name.indexOf("_") != -1) {
			first = name.indexOf("_");
			if (first != name.length()) {
				newString = newString + name.substring(0, first) + "";
				name = name .substring(first + "_".length(), name.length());
				name = firstCharacterToUpper(name);
			}
		}
		newString = newString + name;
		return newString;
	}
	
	/** 
	* 首字母大写 
	*  
	* @param srcStr 
	* @return 
	*/  
	public static String firstCharacterToUpper(String srcStr) {  
	   return srcStr.substring(0, 1).toUpperCase() + srcStr.substring(1);  
	} 
}
